adduser github-action
asswd passwd github-action
ssh-keygen -t rsa -C 'github-action' -f ~/.ssh/github_action
# ssh-copy-id
ssh-copy-id -i ~/.ssh/github_action.pub [email protected]
Host nnnnzs.cn
HostName github-action
User github-action
Port 22
PreferredAuthentications publickey
IdentityFile /Users/nnnnzs/.ssh/github_action
UseKeychain yes
AddKeysToAgent yes
sudo chmod -R 777 /dist
https://github.com/NNNNzs/upload/settings/secrets/actions
mkdir -p .github/workflows
touch .github/workflows/build.yml
name: vue3
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout code
uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '14'
- name: install
run: npm install
- name: build
run: npm run build
- name: deploy
uses: appleboy/scp-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{secrets.KEY}}
port: ${{ secrets.PORT }}
source: "./dist/"
target: ${{secrets.PATH}}
curl -H "Content-Type:application/json" -X POST -d '{"title":"自动部署","content":"upload部署完成","url":"https://api.nnnnzs.cn/upload"}' https://api.nnnnzs.cn/Api/msg
curl -H "Content-Type:application/json" -X POST -d '{"uid":"123"}' http://127.0.0.1:3000/rest/test